
import { Navigate, createBrowserRouter } from "react-router-dom";
import App from "../App";

// zxr
import BackLogin from "../components/BackLogin";
import Forgot from "../components/Forgot";
import Backhome from "../components/Backhome";
import Working from "../components/Working";

import ExamManage from "../components/lzh/ExamManage";
import ExamList from "../components/lzh/ExamList";
import ExamAdd from "../components/lzh/Add/ExamAdd";
import Topic from "../components/lzh/Add/Topic";
import Setting from "../components/lzh/Add/Setting";
import User from "../components/ljc/User";
import Student from "../components/ljc/Student";

import Management from "../components/hwb/Management";
import Topic1 from "../components/hwb/Topic";
import Increased from "../components/hwb/Increased";
import Achievement from '../components/Achievement';
import Show from '../components/Show';

import Home from '../components/Lzx_home'
import Paper from '../components/Lzx_paper'
import Questions from '../components/Lzx_questions'

let CkToken = function(props){
    let Com = props.children.type
    if(sessionStorage.getItem('uid')){
        return <Com></Com>
    }else{
        return <Navigate to='/backlogin'></Navigate>
    }
}



let router = createBrowserRouter([
    {

        path: '/', element: <App></App>,
        children: [
            { path: '/', element: <Navigate to="/backlogin" /> },
            {
                path: '/forgot',
                element: <Forgot></Forgot>
            },
            {
                path: '/backlogin',
                element: <BackLogin></BackLogin>
            },
            {
                path: '/questions',
                element: <Questions></Questions>
            },
            {
                path: '/home',
                element: <CkToken><Backhome></Backhome></CkToken>,
                children: [
                    {
                        path: '/home/working',
                        element: <Working></Working>
                    },
                    {
                        path: '/home/shou',
                        element: <Home></Home>
                    },
                    {
                        path: '/home/paper',
                        element: <Paper></Paper>
                    },
                    { path: '/home/user', element: <User></User> },
                    { path: '/home/student', element: <Student></Student> },
                    { path: '/home/examManage', element: <ExamManage /> },
                    { path: '/home/examList', element: <ExamList /> },
                    {path:'/home/management',element:<Management></Management>,},
                    {path:'/home/topic',element:<Topic1></Topic1>,},
                    {path:'/home/increased',element:<Increased></Increased>,},
                    {
                        path: '/home/examAdd', element: <ExamAdd />, children: [
                            { path: '/home/examAdd/topic', element: <Topic /> },
                            { path: '/home/examAdd/setting', element: <Setting /> },
                        ]
                    },
                    {
                        path:"/home/achievement",
                        element:<Achievement></Achievement>,
                    },
                    {
                        path:"/home/show",
                        element:<Show></Show>,
                    },
                    {
                        path: '/home',
                        element: <Navigate to='/home/working'></Navigate>
                    }
                ]
            }

        ]
    },
])
export default router;